Ext.define('AM.controller.UserList', {
    extend: 'Ext.app.Controller',

    stores: ['Users@AM.store', 
			'UserMemberOf@AM.store' ],

    models: ['User@AM.model'],

    views: ['UsersGrid@AM.view.user', 
			'UserMemberOfView@AM.view.user'],

	refs: [
		{ ref: 'userMemberOfView', selector: 'userMemberOfView', },
	],

    init: function(){
    	this.control({
            'usersGrid': {
                itemdblclick: this.editUser,
                itemclick: this.selectionChange
            }
        });
    },

    editUser: function(grid, record) {
    	Ext.Msg.alert("You doble clicked row " + record.data.name);
    },

    selectionChange: function(grid, record) {
		var view = this.getUserMemberOfView();
		view.getStore().load({url:'http://localhost/Rest01/Service1.svc/userMemberOf/' + record.data.Name});		
    }
});